<h1>Bonjour <?php echo Yii::app()->user->getState('dbuser')->fullName; ?></h1>

<?php 
if (count($projects) == 0) {
	echo "Vous n'avez pas encore de projet, vous pouvez ".CHtml::link("en créer un", array('create')).".";
} else {
?>
Voici la liste de vos projets :
<table class="dataGrid">
	<thead>
		<tr>
			<th><?php echo Yii::t('database', 'Activity'); ?></th>
			<th width="150"><?php echo Yii::t('views', 'Last update'); ?></th>
			<th width="200"><?php echo Yii::t('views', 'Progress'); ?></th>
			<th width="200"><?php echo Yii::t('views', 'Actions'); ?></th>
		</tr>
	</thead>
	<tfoot>
		<tr class="<?php echo $n%2?'odd':'even';?>">
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td align="right"><?php echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl . '/images/add.png', Yii::t('submenu', 'New'))."&nbsp;".Yii::t('submenu', 'New'), array('create')); ?></td>
		</tr>
	</tfoot>
<?php 

foreach ($projects as $n=>$project) {
	?>
	<tr class="<?php echo $n%2?'even':'odd';?>">
		<td><?php echo CHtml::link($project->activity."&nbsp;", array('show', 'id' => $project->id)); ?></td>
		<td align="center"><?php echo Constants::showSqlDate($project->lastMeeting->meeting_date); ?></td>
		<td align="center"><?php 
	$nb=0;
	$complete=0;
	foreach ($project->topics as $topic) {
		$nb++;
		if ($topic->owner_validation) {
			$complete++;
		}
	}
	
	if ($nb > 0)
	echo CHtml::image(CHtml::normalizeUrl(array('gauge', 'pc'=>(100*$complete/$nb), 'width' => 180)), Yii::t('views', 'Gauge'));
		?></td>
		<td align="right"><?php 
	echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl . '/images/edit.png', Yii::t('submenu', 'Update'))."&nbsp;".Yii::t('submenu', 'Update'), array('show', 'id' => $project->id));
	echo "&nbsp;|&nbsp;";	
	echo CHtml::linkButton(CHtml::image(Yii::app()->request->baseUrl . '/images/del.png', Yii::t('submenu', 'Delete'))."&nbsp;".Yii::t('submenu', 'Delete'), array(
		'submit' => array ('delete','id' => $project->id),
		'confirm' => Yii::t('views', 'Are you sure you want to delete this project ?')
	));
	?></td>
	</tr>
<?php 
} 
?>
</table>

<?php 
}


